﻿<%@ Page Title="" Language="C#" MasterPageFile="~/UserControl/UI/MainSite.Master" AutoEventWireup="true" CodeBehind="CoinApply.aspx.cs" Inherits="UI.Module.Coin.CoinApply" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <h2 class="mbx">收益提现 &gt; 提现操作 &gt; 提现</h2>
    <div class="morebt"></div>
    <form id="form1" runat="server">
        <input id="hidBankID" type="hidden" runat="server" value="0" />
        <div class="cztable">
            <asp:Repeater ID="Repeater1" runat="server">
                <HeaderTemplate>
                    <table width="100%">
                </HeaderTemplate>
                <ItemTemplate>
                    <tr style="line-height: 25px;">
                        <td style="width: 5%;">
                            <input id="Radio1" type="radio" name="bankmsg" value='<%#Eval("id")%>' onclick="ChoiceType(this.value)" />

                        </td>
                        <td style="width: 15%;">
                            <asp:Label ID="lblTrueName" runat="server" Text='<%#Eval("BankCardOwner")%>'></asp:Label>

                        </td>
                        <td style="width: 40%;">
                            <asp:Label ID="lblTel" runat="server" Text='<%#Eval("BankCode")%>'></asp:Label>
                        </td>
                        <td style="width: 20%;">
                            <asp:Label ID="Label1" runat="server" Text='<%#Eval("BankName")%>'></asp:Label>
                        </td>
                       <td style="width:10%; text-align:center;" >
                           <asp:LinkButton ID="btnDelete" runat="server" CommandName='<%#Eval("id") %>' OnCommand="btnDelete_Click" OnClientClick=" if(confirm('确实要删除银行卡信息?'))return true;">删除</asp:LinkButton>
                       </td>
                    </tr>
                </ItemTemplate>
                <FooterTemplate></table></FooterTemplate>
            </asp:Repeater>
            <div id="addAccount_wrap">
                <style>
                    #newAccountBtn {
                        background: rgb(54,143,223);
                        padding: 0px 30px;
                        color: white;
                        height: 30px;
                        line-height: 30px;
                        border: none;
                        border-radius: 4px;
                        cursor: pointer;
                    }

                    .accountBtn {
                        background: rgb(54,143,223);
                        padding: 0px 30px;
                        color: white;
                        height: 30px;
                        line-height: 30px;
                        border: none;
                        border-radius: 3px;
                        cursor: pointer;
                        margin: 0 20px;
                    }

                    .button_td {
                        text-align: center;
                    }

                    .account_input {
                        width: 300px;
                        height: 25px;
                        line-height: 25px;
                        border: 1px solid #ccc;
                        border-radius: 3px;
                        font-size: 14px;
                    }

                    .account_select {
                        width: 300px;
                        height: 27px;
                        line-height: 27px;
                        border: 1px solid #ccc;
                        border-radius: 3px;
                        font-size: 14px;
                    }
                </style>
                <input type="button" value="添加提现账户" onclick="newAccount(this);" id="newAccountBtn" />
                <div style="height: 5px;"></div>
                <script>
                    function newAccount(obj) {
                        var _self = obj;
                        _self.disabled = true;
                        $("#addWindowTable").css("display", "");
                    }

                    function hideAddWindow(obj) {
                        $("#addWindowTable").css("display", "none");
                        $("#newAccountBtn")[0].disabled = false;
                    }

                    function checkInput1(obj) {
                        var _self = obj;
                        _self.disabled = true;
                        var type_id = '<%=DropDownList1.ClientID %>';
                        var bankType = $("#" + type_id).val();
                        var account_code = $("#account_code").val();
                        if (account_code == "") {
                            alert("请输入银行卡卡号"); _self.disabled = false; return false;
                        }
                        if (account_code.length < 16 || account_code.length>23) {
                            alert("请输入16-19位有效的银行卡号"); _self.disabled = false; return false;
                        }
                        var account_name = $("#account_name").val();
                        if (account_name == "") {
                            alert("请输入开卡人姓名"); _self.disabled = false; return false;
                        }
                        if (!/^[\u4e00-\u9fa5]{2,4}$/.test(account_name)) {
                            alert("请输入有效的中文名称"); _self.disabled = false; return false;
                        }
                        //$("#btnADD").css("display", "none");
                        //$("#btnADD1").css("display", "block");

                        InvestorAddBankInfo.AddBankInfo(bankType, account_code, account_name, function (data) {
                            
                            var obj = $.parseJSON(data);
                            if (obj.ok) {
                                jBox.alert(obj.message, "提示");
                                setTimeout(function () {
                                    window.location.reload();
                                }, 3500);
                            }
                            else {
                                jBox.tip(obj.message, 'error');
                                _self.disabled = false;
                            }
                        });
                    }
                    function clearNoNum(obj) {
                        obj.value = obj.value.replace(/[^\d.]/g, "");  //清除“数字”和“.”以外的字符  

                        obj.value = obj.value.replace(/^\./g, "");  //验证第一个字符是数字而不是. 

                        obj.value = obj.value.replace(/\.{2,}/g, "."); //只保留第一个. 清除多余的. 

                        obj.value = obj.value.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");

                        var strs = "";
                        var midd = "";
                        var count = 0;
                        for (var i = 0; i < obj.value.length; i++) {
                            if (obj.value.charAt(i) == ".")
                            { midd = "start"; }
                            if (midd == "start")
                            { count++; }
                            if (count == 4)
                            { break; } strs += obj.value.charAt(i);
                        } obj.value = strs;

                    }
                    function getEvent() {
                        if (document.all) {
                            return window.event;
                        }
                        func = getEvent.caller;
                        while (func != null) {
                            var arg0 = func.arguments[0];
                            if (arg0) {
                                if ((arg0.constructor == Event || arg0.constructor == MouseEvent) || (typeof (arg0) == "object" && arg0.preventDefault && arg0.stopPropagation)) {
                                    return arg0;
                                }
                            }
                            func = func.caller;
                        }
                        return null;
                    }
                    window.onload = function () {
                        document.getElementById("account_code").onkeydown = function () {
                            var ev = getEvent();
                            if (!((ev.keyCode > 47 && ev.keyCode < 58) || ev.keyCode == 8 || (ev.keyCode > 95 && ev.keyCode < 106))) return false;
                        };

                        document.getElementById("account_code").onkeyup = function () {
                            this.value = this.value.replace(/\s/g, '').replace(/(\d{4})(?=\d)/g, "$1 ");
                        };
                    };
                </script>
                <table width="100%" cellspacing="0" cellpadding="0" style="display: none;" id="addWindowTable">
                    <tr>
                        <td>银行名称：</td>
                        <td>
                            <asp:DropDownList ID="DropDownList1" runat="server" class="account_select"></asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <td>银行卡卡号：</td>
                        <td>
                            <input type="text" class="account_input" id="account_code" maxlength="23" /></td>
                    </tr>
                    <tr>
                        <td>开卡人姓名：</td>
                        <td>
                            <input type="text" class="account_input" id="account_name" /></td>
                    </tr>
                    <tr>
                        <td colspan="2" class="button_td">
                            <input class="accountBtn" id="btnADD" type="button" onclick="return checkInput1(this)" value="添加" />
                            <input class="accountBtn" id="btnADD1" type="button" value="正在提交..." style="display:none;" />
                            <input class="accountBtn" type="button" value="取消" onclick="hideAddWindow(this);" />
                        </td>
                    </tr>
                </table>
            </div>
            <br />
            <table width="100%" cellpadding="0" cellspacing="0">
                <style>
                    .tx_input {
                        border: 1px solid #ccc;
                        border-radius: 3px;
                        height: 25px;
                        line-height: 25px;
                        font-size: 14px;
                    }

                    .tx_tr {
                        height: 40px;
                    }

                    .tx_submit {
                        height: 28px;
                        line-height: 28px;
                        font-size: 14px;
                        color: white;
                        background: rgb(54,143,223);
                        text-align: center;
                        padding: 0 20px;
                        border: none;
                        border-radius: 3px;
                        cursor: pointer;
                    }
                </style>
                <tr class="tx_tr">
                    <td align="right">可提现金额：</td>
                    <td>
                        <asp:Label ID="lblCoin" runat="server" Text="Label"></asp:Label>元
                    </td>
                </tr>
                <tr class="tx_tr">
                    <td align="right" width="110">申请提现金额：</td>
                    <td colspan="3">
                        <asp:TextBox ID="txtApplyCoin" runat="server" CssClass="tx_input" onkeyup="clearNoNum(this)" MaxLength="8"></asp:TextBox>&nbsp;&nbsp;元
                    </td>
                </tr>
                <tr class="tx_tr">
                    <td align="right" width="110">提现密码：</td>

                    <td colspan="3">
                        <asp:TextBox ID="txtpwd" runat="server" TextMode="Password" CssClass="tx_input" ></asp:TextBox></td>
                </tr>
                <tr class="tx_tr">
                    <td colspan="4" style="text-align: center;">
                        <asp:Button CssClass="tx_submit" ID="Button1" runat="server" Text="提交申请" OnClientClick="return checkInput();" OnClick="Button1_Click" />
                    </td>
                </tr>
            </table>
        </div>
    </form>
    <script src="../../js/jquery-1.4.1.js"></script>
    <script type="text/javascript">
        var hidBankID = '<%=hidBankID.ClientID %>';
        $(function () {
            var banklist = $('input:radio[name="bankmsg"]');
            var bankID = $("#" + hidBankID).val();

            banklist.each(function () {
                if ($(this).val() == bankID) {
                    $(this).attr("checked", "true");
                }
            })
        });
        function ChoiceType(v) {
            $("#" + hidBankID).val(v);
        }

        function checkInput() {
            var jeTextId = '<%=lblCoin.ClientID %>';
            var jeInputId = '<%=txtApplyCoin.ClientID %>';
            var jePwdId = '<%=txtpwd.ClientID %>';
            var tx_je = $("#" + jeInputId).val();

            if ($("#" + hidBankID).val()==0) {
                alert("请选择提现银行信息");
                return false;
            }

            if (tx_je == "") {
                alert("请输入提现金额");
                //$.jBox.tip("请输入提现金额！", 'error');
                return false;
            }
            if (tx_je == 0) {
                alert("提现金额必须大于0");
                return false;
            }



            var tx_max = $("#" + jeTextId).html();
            if (Number(tx_je) > Number(tx_max)) {
                alert("允许提现的最大金额为：" + tx_max + "，你的提现金额为：" + tx_je);
                return false;
            }
            var tx_mm = $("#" + jePwdId).val();
            if (tx_mm == "") {
                alert("请输入提现密码");
                return false;
            }
            return true;
        }
    </script>
</asp:Content>
